package com.mingzhi.principles.demo2.after;

public class RectangleDemo {
    public static void main(String[] args) {
        //创建长方形对象
        Rectangle rectangle = new Rectangle();
        rectangle.setLength(20);
        rectangle.setWidth(10);
        resize(rectangle);
        printLengthAndWidth(rectangle);
        System.out.println("-------------");
        Square square = new Square();
        square.setSide(20);
        printLengthAndWidth(square);

    }

    //扩宽的方法
    public static void resize(Rectangle rectangle) {
        while (rectangle.getWidth() <= rectangle.getLength()) {
            rectangle.setWidth(rectangle.getWidth()  + 1);
        }
    }

    //打印长宽的方法
    public static void printLengthAndWidth(Quadrilateral quadrilateral) {
        System.out.println("length:" + quadrilateral.getLength());
        System.out.println("width:" + quadrilateral.getWidth());
    }
}
